package weaver.interfaces.expense.action.gzc.th;

import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.interfaces.util.ExpenseCompare;
import weaver.interfaces.util.ExpenseCompareUtil;
import weaver.interfaces.util.ExpenseInfoUtil;
import weaver.interfaces.workflow.action.Action;
import weaver.soa.workflow.request.RequestInfo;
/**
 * 
 * @ClassName: CYSJSG_TH_ExpenseAction
 * @Description: 5.常用试剂申购单预算退回
 * @author xiyufei
 * @date 2017-3-20 上午11:19:21 
 *
 */
public class CYSJSG_TH_ExpenseAction  extends BaseBean{

 
	public void execute(String workflowid,String requestid) { 
 
			writeLog("进入CYSJSG_TH_ExpenseAction-----------"+requestid);
			RecordSet rs = new RecordSet(); 
			rs.executeSql("select formid from workflow_base where id = " + workflowid);
			rs.next();
			String formid = rs.getString("formid");
			String formtable = "formtable_main_" + formid.replaceAll("-", "");
			String iskt="0";
			String ccode = "";
			double amount = 0;
			String cexpenseitemcode = "";
			String citemcode = "";
			String ly = "";
			String iyear = "";
			//System.out.println("select  id,ks,cexpenseitemcode,citemcode,zje,zjly,sqrq,kth from "+formtable+" where requestid="+requestid);
			rs.execute("select id,ks,zcxm,xm,zjine,zj,sqrq,kth1 from "+formtable+" where requestid="+requestid);
			rs.next(); 
			ExpenseInfoUtil expenseInfoUtil = new ExpenseInfoUtil();
			ccode =  expenseInfoUtil.getKsbm(Util.null2String(rs.getString("ks"))); 
			amount =  Util.getDoubleValue(rs.getString("zjine"),0); 
			citemcode=  Util.null2String(rs.getString("xm")); 
			cexpenseitemcode=  Util.null2String(rs.getString("zcxm"));  
			String kth =  Util.null2String(rs.getString("kth1"));  
			ly =  Util.null2String(rs.getString("zj"));  
			iyear =  Util.null2String(rs.getString("sqrq")).substring(0,4);   
			if("0".equals(ly)||"6".equals(ly)){//资金来源为课题或者临床试验经费时 课题号+项目支出
				iskt="1";
			}
			if("1".equals(ly)){//财政拨款 课题号
				iskt="1";
			}
			if(!"5".equals(ly)){//非会议类
				boolean bl = expenseInfoUtil.releaseExpense3(workflowid, ccode, cexpenseitemcode, citemcode, kth, amount, iyear,iskt);
			} 
	}

}
